#!/usr/bin/perl

use warnings;
use strict;

open (SAMPLE, "sample.file");

my $i = 1;
foreach (<SAMPLE>) {
    if ( $i >= 3 && $i <= 5) {
        if ( /(.*):.*:.*:.*:(.*)/ ) {
            printf "%s earns %d every month.\n", $1, $2;
        }
    }
    $i++;
}

close SAMPLE;
